<template>
  <div id="app">
    <router-view/>
  </div>
</template>

<script>
import Header from './components/Header.vue'
export default {
  name: 'App',
  components: {Header},
  methods: {
    async handleLogout() {
      try {
        await this.$confirm('确定要退出登录吗？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
        localStorage.removeItem('token')
        this.$store.commit('CLEAR_PROFILE')
        this.$router.replace('/login')
      } catch (_) {}
    }
  },
  watch: {
    // 监听路由
    $route(to, from) {
      if (to.path != '/login') {
        let tabObj = {
          icon: to.meta.icon,
          name: to.name,
          title: to.meta.title
        }
        this.$store.commit('addTabs', tabObj)
      }
    }
  }
}
</script>

<style>
html,
body,
#app {
  height: 100%;
  padding: 0;
  margin: 0;
  font-size: 14px;
  font-family: "微软雅黑";
  color: #494949;
  text-align: left;
}

:root {
  --primary: #8B5A2B;
  --secondary: #D2B48C;
  --dark: #3E2723;
}
</style>
